//
//  QPDetectParam.m
//  QPJHLightSDK
//
//  Created by Vanney on 2021/5/13.
//  Copyright © 2021 Vanney. All rights reserved.
//

#import "SQPDetectParam.h"
#import "QPJHFunRoleModel.h"
#import "QPJFunPayModel.h"
#import "QPSaccountStore.h"
#import "UIView+Toast.h"
#import "QPJHFunDataFormat.h"

@implementation SQPDetectParam


- (BOOL)qp_detectContainsEmptyString:(QPJHFunRoleModel *)roleInfo {
    
    if ([QPJHFunDataFormat isBlankString:roleInfo.super_user_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"未检测到您的登录信息"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.role_type]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"上报类型为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.service_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"区服ID为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.service_name]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"区服名称为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.role_name]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"角色名为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.role_level]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"角色等级为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.game_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"填入的游戏ID有误"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.role_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"角色ID为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.platform_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"未检测到您的初始化信息"];
        return YES;
    }
    return NO;
}
- (QPJHFunRoleModel *)qp_handleRoleParam:(QPJHFunRoleModel *)roleInfo {
    if ([QPJHFunDataFormat isBlankString:roleInfo.power_value]) {
        roleInfo.power_value = @"1";
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.experience] || [roleInfo.experience intValue] == 0) {
        roleInfo.experience = @"1";
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.describe]) {
        roleInfo.describe = @"";
    }
    if ([QPJHFunDataFormat isBlankString:roleInfo.money] || [roleInfo.money intValue] == 0) {
        roleInfo.money = @"1";
    }
    return roleInfo;
}


- (BOOL)qp_detectPayContainsEmptyString:(QPJFunPayModel *)payInfo {
    if ([QPJHFunDataFormat isBlankString:payInfo.role_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"role_id为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.super_role_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"未检测到您的角色信息"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.super_user_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"未检测到您的登录信息"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.good_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"商品ID为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.good_name]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"商品名称为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.platform_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"未检测到您的初始化信息"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.game_order_sn]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"订单号为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.money]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"支付金额为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.service_id]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"区服id为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.service_name]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"区服名称为空"];
        return YES;
    }
    if ([QPJHFunDataFormat isBlankString:payInfo.role_name]) {
        [[[QPSaccountStore sharedInstance] getCurrentWindow] makeToast:@"角色名为空"];
        return YES;
    }
    return NO;
}

- (QPJFunPayModel *)qp_handlePayParam:(QPJFunPayModel *)payInfo RoleInfo:(QPJHFunRoleModel *)roleInfo {
    if ([QPJHFunDataFormat isBlankString:payInfo.remark]) {
        payInfo.remark = @"";
    }

    return payInfo;
}

@end
